home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Object = "{C7212F93-30E8-11D2-B450-0020AFD69DE6}#1.0#0"; "SocketX.OCX"
- Begin VB.Form Form1
- Caption = "Form1"
- ClientHeight = 6945
- ClientLeft = 1095
- ClientTop = 1485
- ClientWidth = 7365
- BeginProperty Font
- Name = "MS Sans Serif"
- Size = 8.25
- Charset = 0
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- ForeColor = &H80000008&
- KeyPreview = -1 'True
- LinkTopic = "Form1"
- PaletteMode = 1 'UseZOrder
- ScaleHeight = 6945
- ScaleWidth = 7365
- Begin SocketXCtl.SocketXCtl SocketX
- Left = 600
- Top = 6000
- AcceptTimeout = 0
- BlockingMode = -842150451
- Blocking = -1 'True
- BroadcastEnabled= -1 'True
- ConnectTimeout = 0
- EventMask = 63
- KeepAliveEnabled= 0 'False
- LibraryName = "WSOCK32.DLL"
- LingerEnabled = 0 'False
- LingerMode = 0
- LingerTime = 0
- LocalAddress = ""
- LocalPort = 0
- OutOfBandEnabled= 0 'False
- ReceiveBufferSize= 8192
- ReceiveTimeout = 0
- RemoteAddress = ""
- RemoteName = ""
- ReuseAddressEnabled= 0 'False
- RemotePort = 0
- RouteEnabled = -1 'True
- SendTimeout = 8192
- SendBufferSize = 0
- SocketType = 0
- TcpNoDelayEnabled= 0 'False
- End
- Begin VB.TextBox txtPort
- BeginProperty Font
- Name = "MS Sans Serif"
- Size = 8.25
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 285
- Left = 4560
- TabIndex = 6
- Text = "7"
- Top = 5520
- Width = 495
- End
- Begin VB.CheckBox chkLocalEcho
- Caption = "Local Echo"
- BeginProperty Font
- Name = "MS Sans Serif"
- Size = 8.25
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 255
- Left = 5280
- TabIndex = 4
- Top = 5520
- Width = 1215
- End
- Begin VB.CommandButton Command1
- Appearance = 0 'Flat
- BackColor = &H80000005&
- Caption = "Connect"
- BeginProperty Font
- Name = "MS Sans Serif"
- Size = 8.25
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 375
- Left = 120
- TabIndex = 3
- Top = 5520
- Width = 1095
- End
- Begin VB.TextBox txtServer
- BeginProperty Font
- Name = "MS Sans Serif"
- Size = 8.25
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 285
- Left = 2160
- TabIndex = 2
- Text = "12.2.15.57"
- Top = 5520
- Width = 1695
- End
- Begin VB.TextBox txtTranscript
- BeginProperty Font
- Name = "Courier New"
- Size = 8.25
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 5175
- Left = 120
- MultiLine = -1 'True
- ScrollBars = 3 'Both
- TabIndex = 0
- Top = 120
- Width = 7095
- End
- Begin VB.Label Label4
- Caption = "If you are not connecting to a remote echo port (7) you should check the Local Echo box."
- BeginProperty Font
- Name = "MS Sans Serif"
- Size = 8.25
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 855
- Left = 5280
- TabIndex = 8
- Top = 5880
- Width = 2055
- End
- Begin VB.Label Label1
- Alignment = 1 'Right Justify
- Appearance = 0 'Flat
- BackColor = &H00C0C0C0&
- Caption = "Port:"
- BeginProperty Font
- Name = "MS Sans Serif"
- Size = 8.25
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- ForeColor = &H80000008&
- Height = 255
- Left = 4080
- TabIndex = 7
- Top = 5520
- Width = 375
- End
- Begin VB.Label Label3
- Caption = "Note: Not all servers you might choose support connections to all ports."
- BeginProperty Font
- Name = "MS Sans Serif"
- Size = 8.25
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 615
- Left = 2160
- TabIndex = 5
- Top = 6000
- Width = 2055
- End
- Begin VB.Label Label2
- Alignment = 1 'Right Justify
- Appearance = 0 'Flat
- BackColor = &H00C0C0C0&
- Caption = "Server:"
- BeginProperty Font
- Name = "MS Sans Serif"
- Size = 8.25
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- ForeColor = &H80000008&
- Height = 255
- Left = 1440
- TabIndex = 1
- Top = 5520
- Width = 615
- End
- Attribute VB_Name = "Form1"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- Option Explicit
- Implements ISocketXCtlNotify
- Dim transcriptHasFocus As Integer
- Private Sub AddToTranscript(ByVal s As String)
- Dim newtext As String
- Dim i As Integer
- Dim p As Integer
- Dim fixup As Integer
- For i = 1 To Len(s)
- fixup = False
- Select Case Asc(Mid(s, i, 1))
- Case 13
- If (i < Len(s)) Then
- If (Mid(s, i + 1, 1) <> Chr(10)) Then
- fixup = True
- Else
- newtext = newtext & Chr(13)
- End If
- Else
- fixup = True
- End If
- Case 10
- If (i > 1) Then
- If (Mid(s, i - 1, 1) <> Chr(13)) Then
- fixup = True
- Else
- newtext = newtext & Chr(10)
- End If
- Else
- fixup = True
- End If
- Case Else
- newtext = newtext & Mid(s, i, 1)
- End Select
- If (fixup) Then
- newtext = newtext & Chr(13) & Chr(10)
- End If
- Next
- txtTranscript.Text = txtTranscript.Text & newtext
- txtTranscript.SelStart = Len(txtTranscript.Text) + 1
- End Sub
- Private Sub Command1_Click()
- Dim i As Integer
- Dim addr As String
- Dim lookup As Integer
- Dim c As String
- txtTranscript.SetFocus
- Command1.Enabled = False
- If (Command1.Caption = "Disconnect") Then
- SocketX.Close
- Command1.Caption = "Connect"
- Command1.Enabled = True
- Exit Sub
- End If
- SocketX.Create
- addr = txtServer.Text
- '
- ' Check to see if name lookup required
- '
- lookup = False
- For i = 1 To Len(addr)
- c = Mid(addr, i, 1)
- If (c <> "." And (c < "0" Or c > "9")) Then
- '
- ' Found a non-numeric character that is not
- ' a dot, need to do a name lookup
- '
- lookup = True
- Exit For
- End If
- Next
- If (lookup) Then
- SocketX.RemoteNameAddrXlate = True
- SocketX.RemoteName = addr
- txtServer.Text = SocketX.RemoteAddress
- Else
- SocketX.RemoteAddress = addr
- End If
- SocketX.RemoteNameAddrXlate = False
- SocketX.RemotePort = CInt(txtPort.Text)
- SocketX.Connect
- End Sub
- Private Sub Form_KeyPress(keyascii As Integer)
- If (transcriptHasFocus) Then
- If (SocketX.State >= soxConnected) Then
- If (keyascii = 13) Then
- SocketX.SendBuffer = Chr(13) & Chr(10)
- Else
- SocketX.SendBuffer = Chr(keyascii)
- End If
- If (chkLocalEcho.Value = 1) Then
- AddToTranscript CStr(SocketX.SendBuffer)
- End If
- SocketX.Send
- End If
- keyascii = 0
- End If
- End Sub
- Private Sub Form_Load()
- SocketX.SocketType = soxStream
- SocketX.Blocking = False
- SocketX.EventMask = -1
- SocketX.NotificationObject = Me
- End Sub
- Private Sub ISocketXCtlNotify_Accept(ByVal SocketXCtl As SocketXCtl.ISocketXCtl, ByVal SocketHandle As Long, ByVal ErrorCode As Integer)
- AddToTranscript "*** Accept ***"
- End Sub
- Private Sub ISocketXCtlNotify_Close(ByVal SocketXCtl As SocketXCtl.ISocketXCtl, ByVal ErrorCode As Integer)
- AddToTranscript "*** OnClose ***" & Chr(13)
- Command1.Caption = "Connect"
- Command1.Enabled = True
- End Sub
- Private Sub ISocketXCtlNotify_Connect(ByVal SocketXCtl As SocketXCtl.ISocketXCtl, ByVal ErrorCode As Integer)
- If (ErrorCode = 0) Then
- AddToTranscript "*** OnConnect ***" & Chr(13)
- Command1.Caption = "Disconnect"
- ElseIf (ErrorCode = 10060) Then
- AddToTranscript "Connection timed out"
- Else
- AddToTranscript "Unexpected error " & ErrorCode & Chr(13) & " " & SocketXCtl.LastErrorString & Chr(13)
- End If
- Command1.Enabled = True
- End Sub
- Private Sub ISocketXCtlNotify_Done(ByVal SocketXCtl As SocketXCtl.ISocketXCtl, ByVal LastMethod As SocketXCtl.MethodsEnum, ByVal ErrorCode As Integer)
- If (LastMethod <> soxReceive And LastMethod <> soxSend) Then
- AddToTranscript "Done(" & LastMethod & "," & ErrorCode & ")" & Chr(13)
- End If
- End Sub
- Private Sub ISocketXCtlNotify_OutOfBandData(ByVal SocketXCtl As SocketXCtl.ISocketXCtl, ByVal ErrorCode As Integer)
- AddToTranscript "*** Out of band data received ***"
- End Sub
- Private Sub ISocketXCtlNotify_Receive(ByVal SocketXCtl As SocketXCtl.ISocketXCtl, ByVal ErrorCode As Integer)
- SocketXCtl.Receive
- If (ErrorCode = 0) Then
- AddToTranscript CStr(SocketXCtl.ReceiveBuffer)
- Else
- AddToTranscript "*** Receive Error " & ErrorCode & " ***"
- End If
- End Sub
- Private Sub ISocketXCtlNotify_Send(ByVal SocketXCtl As SocketXCtl.ISocketXCtl, ByVal ErrorCode As Integer)
- AddToTranscript "*** Send ***" & Chr(13)
- MsgBox "The Send event occured, you can start typing now."
- End Sub
- Private Sub txtTranscript_GotFocus()
- transcriptHasFocus = True
- End Sub
- Private Sub txtTranscript_LostFocus()
- transcriptHasFocus = False
- End Sub
-